



import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.util.Iterator;
import java.util.List;

import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

import friendShips.User;


	public class Main {

		public static void main(String[] args) {
		 User user = new User();
		 user.setFirstName("Tony");
		 user.setLastName("Lover");
		 user.setEmail("jj");
		 user.setLocation("32,36");
		 user.setPassword("1");
		 user.setOnline(true);
		 

		 SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory(); 
		 Session session = sessionFactory.openSession();
		 UserManager manager = new UserManager(session);

		// manager.saveUser(user);
		 //System.out.println("User saved with ID = "+user.getUserId());
		 //session.flush();
		 
		 Query query = session.createQuery("from User");

		 List <User>list = query.list();
		 Iterator<User> it=list.iterator();

		 while (it.hasNext()){
		  user=it.next();
		  System.out.println("id: \t\t"+user.getUserId());
		  System.out.println("first name: \t"+user.getFirstName());
		  System.out.println("last name: \t"+user.getLastName());
		  System.out.println("email: \t\t"+user.getEmail());
		  System.out.println("lastLocation: \t"+user.getLocation());
		  System.out.println("password: \t"+user.getPassword());


		 }

		 }
		
		}

	
